import Vue from "vue";
import VueRouter from "vue-router";
// import HomeView from "../views/Main.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Main",
    component: () => import("../views/Main.vue"),
    children: [
      {
        path: "/home",
        name: "home",
        component: () => import("../views/home"),
      },
      {
        path: "/about",
        name: "about",
        component: () => import("../views/about"),
      },
      {
        path: "/type",
        name: "type",
        component: () => import("../views/type"),
      },
      {
        path: "/room",
        name: "room",
        component: () => import("../views/room"),
      },
      {
        path: "/checkinList",
        name: "checkinList",
        component: () => import("../views/checkinList"),
      },
      {
        path: "/checkoutList",
        name: "checkoutList",
        component: () => import("../views/checkoutList"),
      },
      {
        path: "/checkin",
        name: "checkin",
        component: () => import("../views/checkin"),
      },
      {
        path: "/customer",
        name: "customer",
        component: () => import("../views/customer"),
      },
      {
        path: "/checkout",
        name: "checkout",
        component: () => import("../views/checkout"),
      },
      {
        path: "/dateDiscount",
        name: "dateDiscount",
        component: () => import("../views/dateDiscount"),
      },
      {
        path: "/wayDiscount",
        name: "wayDiscount",
        component: () => import("../views/wayDiscount"),
      },
    ],
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

const VueRouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch((err) => err);
};

// // 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
// const originalPush = router.prototype.push;
// router.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch((err) => err);
// };

export default router;
